{% extends 'gideon/layout.html' %}
{% if data.permission_enable %}
    {% load oracle %}
{% endif %}

{% block css %}
    <style>
        .form-control.error {
            background: rgb(251, 227, 228);
            border: 1px solid #fbc2c4;
            color: #8a1f11;
        }
    </style>
{% endblock %}

{% block content %}
    <div class="row mt-2">
        <div class="col-lg-10">
            <div class="ibox ">
                <div class="ibox-title">
                    <h5>{{ data.form_name }}</h5>
                    <div class="ibox-tools">
                        {% if data.return_url %}
                            <a class="btn btn-success" type="button" style="color: white!important;"
                               href="{{ data.return_url }}">
                                <i class="fa fa-reply"></i> 回到列表
                            </a>
                        {% endif %}
                        <a class="btn btn-info btn-circle collapse-link" type="button"
                           style="color: white!important;">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal" method="post" novalidate>
                        {% csrf_token %}
                        <p>{{ data.form_description }}</p>
                        {% for field in data.form %}
                            <div class="form-group row col-lg-10
                                {% if field.name == "key" and "key" not in data.show_field or field.name == "status" and "status" not in data.show_field or field.name == "level" and "level" not in data.show_field %}
                                d-none
                                {% endif %}
                                ">
                                <label class="col-lg-2 col-form-label">
                                    {% if field.name == "key" and "key" in data.show_field %} {{ data.show_field.key }}
                                    {% elif field.name == "status" and "status" in data.show_field %} {{ data.show_field.status }}
                                    {% elif field.name == "level" and "level" in data.show_field %} {{ data.show_field.level }}
                                    {% else %} {{ field.label }} {% endif %}
                                </label>
                                <div class="col-lg-10">
                                    {{ field }}
                                    <span id="{{ field.name }}-error" class="error">{{ field.errors.0 }}</span>
                                </div>
                            </div>
                        {% endfor %}
                        <div class="form-group row">
                            <div class="col-lg-offset-2 col-lg-10 mt-3">
                                <button class="btn btn-outline btn-primary dim" type="submit">
                                    <i class="fa fa-check"></i> 保存数据
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
{% endblock %}